package com.yc.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yc.R_Code;
import com.yc.Result;
import com.yc.entities.BloodSugarEquipment;
import com.yc.entities.custom.CustomEquipmentQueryRequestBean;
import com.yc.entities.custom.CustomEquipmentQueryResponseBean;
import com.yc.entities.custom.CustomRoleQueryResponseBean;
import com.yc.mapper.BloodSugarEquipmentMapper;
import com.yc.service.BloodSugarEquipmentService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 设备 服务实现类
 * </p>
 *
 * @author kuakha
 * @since 2021-04-07
 */
@Service
public class BloodSugarEquipmentServiceImpl extends ServiceImpl<BloodSugarEquipmentMapper, BloodSugarEquipment> implements BloodSugarEquipmentService {

    @Override
    public Result getAllEquipmentInfo(CustomEquipmentQueryRequestBean customEquipmentQueryRequestBean) {
        Page<CustomEquipmentQueryRequestBean> page = new Page<>(customEquipmentQueryRequestBean.getCurrent(),customEquipmentQueryRequestBean.getSize());
        List<CustomEquipmentQueryResponseBean> allRoleInfo = this.baseMapper.getAllEquipmentInfo(page, customEquipmentQueryRequestBean);
        if (page.getTotal()>=1){
            return Result.ok().total((int) page.getTotal()).data(allRoleInfo);
        }else {
            return Result.ok().code(R_Code.R_NULL_DATA_FAIL);
        }
    }
}
